<?php
include("assets/pChart/class/pData.class.php");
include("assets/pChart/class/pDraw.class.php");
include("assets/pChart/class/pImage.class.php");

$myData = new pData();
$myData->addPoints($_POST['Array_Num'],"Serie1");
$myData->setSerieDescription("Serie1","Applicants");
$myData->setSerieOnAxis("Serie1",0);

$myData->addPoints($_POST['Array_Dates'],"Absissa");
$myData->setAbscissa("Absissa");

$myData->setPalette("Serie1",array("R"=>172,"G"=>232,"B"=>147,"Alpha"=>100));
$myData->setAxisPosition(0,AXIS_POSITION_LEFT);
$myData->setAxisName(0,"Applies");
$myData->setAxisUnit(0,"");

$myPicture = new pImage(960,400,$myData);
$Settings = array("R"=>255, "G"=>255, "B"=>255, "Dash"=>1, "DashR"=>275, "DashG"=>275, "DashB"=>275);
$myPicture->drawFilledRectangle(0,0,960,400,$Settings);

$Settings = array("StartR"=>255, "StartG"=>255, "StartB"=>255, "EndR"=>255, "EndG"=>255, "EndB"=>255, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,960,400,DIRECTION_VERTICAL,$Settings);

$myPicture->setFontProperties(array("FontName"=>"assets/pChart/fonts/Forgotte.ttf","FontSize"=>14));
$TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE
, "R"=>255, "G"=>255, "B"=>255);
$myPicture->drawText(480,25,"Applies Report",$TextSettings);

$myPicture->setGraphArea(50,50,935,360);
$myPicture->setFontProperties(array("R"=>251,"G"=>98,"B"=>128,"FontName"=>"assets/pChart/fonts/pf_arma_five.ttf","FontSize"=>10));

$Settings = array("Pos"=>SCALE_POS_LEFTRIGHT
, "Mode"=>SCALE_MODE_START0
, "LabelingMethod"=>LABELING_ALL
, "GridR"=>255, "GridG"=>255, "GridB"=>255, "GridAlpha"=>50, "TickR"=>0, "TickG"=>0, "TickB"=>0, "TickAlpha"=>50, "LabelRotation"=>0, "CycleBackground"=>1, "DrawXLines"=>1, "DrawSubTicks"=>1, "SubTickR"=>255, "SubTickG"=>0, "SubTickB"=>0, "SubTickAlpha"=>50, "DrawYLines"=>ALL);
$myPicture->drawScale($Settings);

$Config = array("DisplayValues"=>1, "Rounded"=>1, "AroundZero"=>1);
$myPicture->drawBarChart($Config);

$Config = array("FontR"=>251, "FontG"=>98, "FontB"=>128, "FontName"=>"assets/pChart/fonts/pf_arma_five.ttf", "FontSize"=>12, "Margin"=>6, "Alpha"=>30, "BoxSize"=>5, "Style"=>LEGEND_NOBORDER
, "Mode"=>LEGEND_HORIZONTAL
);
$myPicture->drawLegend(856,16,$Config);
ob_start();
$myPicture->stroke();
$image = ob_get_contents();
ob_end_clean();
if(file_exists('assets/images/chart.png')){
    unlink('assets/images/chart.png');
}
$file = fopen('assets/images/chart.png', 'wb');
fputs($file, $image);
fclose($file);
?>